		#self.developer='asu_'
		#self.project='so_'
		#self.name='el'
		#self.src=firebird
		#self.dst=oracle
		#self.med=postgre
		self.fields_src=[
		['id','integer','NOT NULL','id'],
		['art_id','integer','NOT NULL','Search.articles'],
		['section_id_id','integer','NOT NULL','Search.ssections'],
		['sectname','character varying(70)','NOT NULL','Search.ssections'],
		['doc_type','integer','NOT NULL','Search.doclist'],
		['doc_name','character varying(100)','NOT NULL','Search.doctypes'],
		['designatio','character varying(80)','','Search.articles'],
		['name','character varying(250)','','Search.articles'],
		['mu_id','integer','NOT NULL','Search.articles'],
		['purchased','character(1)','','Search.articles'],
		['format','character varying(200)','','Search.doclist'],
		['modifdate','timestamp','','Search.articles'],
		['version_id','integer','','Search.doclist']]
		self.fields_dest=[
		['id','integer','NOT NULL','id'],
		['unvcode','integer','NOT NULL','Omega.konstrobj'],
		['revision','integer','NOT NULL','Omega.konstrobj'],
		['itemtype','integer','NOT NULL','Omega.konstrobj'],
		['itemtype_name','character varying(40)','NOT NULL','Omega.ko_types.name'],
		['sign','character varying(100)','NOT NULL','Omega.konstrobj'],
		['name','character varying(200)','','Omega.konstrobj'],
		['notice','character varying(100)','','Omega.konstrobj'],
		['meascode','integer','NOT NULL','Omega.konstrobj'],
		['measname','character varying(40)','NOT NULL','Omega.measures.name'],
		['supplytype','integer','NOT NULL','Omega.konstrobj'],
		['format','character varying(15)','','Omega.konstrobj'],
		['owner','integer','NOT NULL','Omega.konstrobj'],
		['owner_name','character varying(100)','NOT NULL','Omega.owner_name'],
		['recdate','timestamp','NOT NULL','Omega.konstrobj'],
		['prodcode','integer','NOT NULL','Omega.konstrobj'],
		['omp_objects_code','integer','NOT NULL','Omega.omp_objects.code'],
		['first_promcode','integer','NOT NULL','Omega.businessobj_promotion.code'],
		['last_promcode','integer','NOT NULL','Omega.businessobj_promotion.code'],
		['current_state','character varying(40)','','Omega.businessobj_states.name'],
		['statedate','timestamp','NOT NULL','Omega.businessobj_promotion.statedate'],
		['lastname','character varying(40)','NOT NULL','Omega.businessobj_promotion.lastname']]
		self.name_src='articles'
		self.name_dest='konstrobj'
		self.query_src='''select 

DISTINCT 

a.art_id, a.section_id, ss.sectname, d.doc_type, e.doc_name, a.designatio, a.name, a.note, a.mu_id, a.purchased, d.format, a.modifdate, d.version_id

     FROM articles a, articles_view av, archives ar, pc, ssections ss, doclist d, doctypes e

          WHERE
               
               e.doc_type=d.doc_type
      
               AND d.doc_id=a.doc_id
               
               AND a.section_id=ss.section_id

               AND extract(YEAR from a.chkindate)>2005

               AND a.art_id>0

               AND ar.archive_id=av.archive_id

               AND (ar.archive_id=31
                        OR ar.archive_id=34
                        OR ar.archive_id=35
                        OR ar.archive_id=36
                        OR ar.archive_id=37
                        OR ar.archive_id=38
                        OR ar.archive_id=41
                        OR ar.archive_id=42
                        OR ar.archive_id=43)

               AND CHAR_LENGTH(TRIM(a.name))>0

               AND 

                (
                 (a.art_id=pc.part_aid
                  OR a.art_id=pc.proj_aid)

                 AND av.art_id=pc.proj_aid
                 AND CHAR_LENGTH(TRIM(a.designatio))>0
                 AND (a.SECTION_ID=1
                          OR a.SECTION_ID=3
                          OR a.SECTION_ID=4
                          OR a.SECTION_ID=8)
                )

UNION ALL

select 

DISTINCT 

a.art_id, a.section_id, ss.sectname, d.doc_type, e.doc_name, a.designatio, a.name, a.note, a.mu_id, a.purchased, d.format, a.modifdate, d.version_id

     FROM 

articles a, articles_view av, archives ar, pc, ssections ss, doclist d, doctypes e

          WHERE
               
               e.doc_type=d.doc_type
      
               AND d.doc_id=a.doc_id

               AND a.section_id=ss.section_id

               AND extract(YEAR from a.chkindate)>2005

               AND a.art_id>0

               AND ar.archive_id=av.archive_id

               AND (ar.archive_id=31
                        OR ar.archive_id=34
                        OR ar.archive_id=35
                        OR ar.archive_id=36
                        OR ar.archive_id=37
                        OR ar.archive_id=38
                        OR ar.archive_id=41
                        OR ar.archive_id=42
                        OR ar.archive_id=43)

               AND CHAR_LENGTH(TRIM(a.name))>0

               AND 
                
                (
                 a.art_id=pc.part_aid
                 AND av.art_id=pc.proj_aid
                 AND CHAR_LENGTH(TRIM(a.designatio))=0
                 AND (a.SECTION_ID=5
                          OR a.SECTION_ID=6
                          OR a.SECTION_ID=7)
                )'''
		self.query_dest='''SELECT a.UNVCODE, a.REVISION, a.ITEMTYPE, b."NAME" AS "ITEMTYPE_NAME", a.SIGN,
a."NAME", a.NOTICE, a.MEASCODE, c."NAME" as MEASNAME, a.SUPPLYTYPE, a.FORMAT, 
a.OWNER, d."NAME" as "OWNER_NAME", a.RECDATE, a.PRODCODE, e.CODE as "OMP_OBJECTS_CODE",
g.CODE as "FIRST_PROMCODE", h.CODE as "LAST_PROMCODE", i.CURRENT_STATE, i.STATEDATE, i.LASTNAME


FROM OMP_ADM.KONSTROBJ a, OMP_ADM.KO_TYPES b, 
    OMP_ADM.MEASURES c, OMP_ADM.OWNER_NAME d,
    OMP_ADM.BUSINESS_OBJECTS e,
    
    (SELECT a.DOCCODE as "UNVCODE", MIN(b.CODE) AS "CODE"
        FROM OMP_ADM.BUSINESS_OBJECTS a, OMP_ADM.BUSINESSOBJ_PROMOTION b, OMP_ADM.BUSINESSOBJ_STATES c
            WHERE b.BUSINESSOBJ=a.CODE
                AND c.CODE=b.CURRENT_STATE
                AND a."TYPE" IN (0,1,2,3,4,5,6,22)
        GROUP BY a.DOCCODE) g,

    (SELECT a.DOCCODE as "UNVCODE", MAX(b.CODE) AS "CODE"
        FROM OMP_ADM.BUSINESS_OBJECTS a, OMP_ADM.BUSINESSOBJ_PROMOTION b, OMP_ADM.BUSINESSOBJ_STATES c
            WHERE b.BUSINESSOBJ=a.CODE
                AND c.CODE=b.CURRENT_STATE
                AND a."TYPE" IN (0,1,2,3,4,5,6,22)
        GROUP BY a.DOCCODE) h,

    (SELECT a.CODE, b."NAME" as "CURRENT_STATE", a.STATEDATE, a.LASTNAME 
        FROM OMP_ADM.BUSINESSOBJ_PROMOTION a, OMP_ADM.BUSINESSOBJ_STATES b
            WHERE b.CODE=a.CURRENT_STATE) i

            
            WHERE b.CODE=a.ITEMTYPE
                AND c.CODE=a.MEASCODE
                AND d.OWNER=a.OWNER
                AND e.DOCCODE=a.UNVCODE
                AND e."TYPE"=a.ITEMTYPE
                AND g.UNVCODE=a.UNVCODE
                AND h.UNVCODE=a.UNVCODE
                AND h.CODE=i.CODE
                AND a.ITEMTYPE IN (0,1,2,3,4,5,6,22)'''




class src_tb(src_tb):
	"""This class is a manipulator for source table"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(src_tb, self).__init__()

class src_vw(src_vw):
	"""This class is a manipulator for source view"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(src_vw, self).__init__(object())

class dest_tb(dest_tb):
	"""This class is a manipulator for destination table"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(dest_tb, self).__init__(object())

class dest_vw(dest_vw):
	"""This class is a manipulator for destination view"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(dest_vw, self).__init__(object())

class inter_src(inter_src):
	"""This class is a manipulator for source in intermediate db"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(inter_src, self).__init__(object())

class inter_dest(inter_dest):
	"""This class is a manipulator for destination in intermediate db"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(inter_dest, self).__init__(object())

class inter_map(inter_map):
	"""This class is a manipulator for map in intermediate db"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		super(inter_map, self).__init__(object())









#from firebird import atable as firebird_tb
#from firebird import aview as firebird_vw
#from postgre import atable as postgre_tb
#from postgre import aview as postgre_vw
#from oracle import atable as oracle_tb
#from oracle import aview as oracle_vw
#from mysql import atable as mysql_tb
#from mysql import aview as mysql_vw

		self.src_tb=self.source.module.atable()
		self.src_vw=self.source.module.aview()
		self.dst_tb=self.destination.module.atable()
		self.dst_vw=self.destination.module.aview()
		self.med_src=self.intermediate.module.atable()
		self.med_dst=self.intermediate.module.atable()
		
		self.src_tb.name=''
		self.src_tb.fields=[[]]
		self.src_tb.primary=''
		self.src_tb.comment=''
		
		self.src_vw.name=''
		self.src_vw.fields=[]
		self.src_vw.query=''
		
		self.dst_tb.name=''
		self.dst_tb.fields=[[]]
		self.dst_tb.primary=''
		self.dst_tb.comment=''
		
		self.dst_vw.name=''
		self.dst_vw.fields=[]
		self.dst_vw.query=''
		
		self.med_src.name=''
		self.med_src.fields=[[]]
		self.med_src.primary=''
		self.med_src.comment=''
		
		self.med_dst.name=''
		self.med_dst.fields=[[]]
		self.med_dst.primary=''
		self.med_dst.comment=''
		self.med_map=self.intermediate.module.atable()
		self.med_map.name=''
		self.med_map.fields=[[]]
		self.med_map.primary=''
		self.med_map.comment=''
		
		
			
		
			
		
			
		
			
		
			
			
			
			
			
			
			
			
			
class object:
	"""This class is a manipulator for import object"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self):
		self.prefix='x_'
		self.developer='_'
		self.project='_'
		self.name='_'
		self.src=None
		self.dest=None
		self.inter=None
		self.fields_src=[[]]
		self.fields_dest=[[]]
		self.name_src=''
		self.name_dest=''
		self.query_src=''
		self.query_dest=''

	def columns(self, fields):
		columns=[]
		for list in fields[1:]:
			columns+=[list[0]]
		return columns

	#end of class object suite

class src_tb:
	"""This class is a manipulator for source table"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, name=self.object()):
		self.object=object
		self.name=self.object.name_src
		self.atable=self.object.src.atable()
		self.atable.name=self.name

	def _countself(self):
		return self.atable.countself()
		
	def _select(self, columns=[], clause=[]):
		return self.atable.select(columns, clause)
		
	def _count(self, clause=[]):
		return self.atable.count(clause)

	#end of class src_tb suite

class src_vw:
	"""This class is a manipulator for source view"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, object):
		self.object=object
		self.name=self.object.prefix+self.object.developer+self.object.project+self.object.name+self.object.name_src
		self.fields=self.object.columns(self.object.fields_src)
		self.query=self.object.query_src
		self.aview=self.object.src.aview()
		self.aview.name=self.name
		self.aview.fields=self.fields
		self.aview.query=self.query
	
	def _countself(self):
		return self.aview.countself()
		
	def _create(self):
		return self.aview.create()
		
	def _drop(self):
		return self.aview.drop()
	
	def _select(self, columns=[], clause=[]):
		return self.aview.select(columns, clause)
	
	def _count(self, clause=[]):
		return self.aview.count(clause)

	#end of class src_vw suite

class dest_tb:
	"""This class is a manipulator for destination table"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, object):
		self.object=object
		self.name=self.object.name_dest
		self.atable=self.object.dest.atable()
		self.atable.name=self.name
	
	def __countself(self):
		return self.atable.countself()
		
	def __select(self, columns=[], clause=[]):
		return self.atable.select(columns, clause)
		
	def _count(self, clause=[]):
		return self.atable.count(clause)
		
	def _delete(self, clause=[]):
		return self.atable.delete(clause)

	def _update(self, dict, clause=[]):
		return self.atable.update(dict, clause)

	def _insert(self, fields, values):
		return self.atable.insert(fields, values)

	#end of class dest_tb suite

class dest_vw:
	"""This class is a manipulator for destination view"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, object):
		self.object=object
		self.name=self.object.prefix+self.object.developer+self.object.project+self.object.name+self.object.name_dest
		self.fields=self.object.columns(self.object.fields_dest)
		self.query=self.object.query_dest
		self.aview=self.object.dest.aview()
		self.aview.name=self.name
		self.aview.fields=self.fields
		self.aview.query=self.query
	
	def _countself(self):
		return self.aview.countself()
		
	def _create(self):
		return self.aview.create()
		
	def _drop(self):
		return self.aview.drop()
	
	def _select(self, columns=[], clause=[]):
		return self.aview.select(columns, clause)
	
	def _count(self, clause=[]):
		return self.aview.count(clause)

	#end of class dest_vw suite

class inter_src:
	"""This class is a manipulator for source in intermediate db"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, object):
		self.object=object
		self.name=self.object.prefix+self.object.developer+self.object.project+self.object.name+'_src'
		self.fields=self.object.fields_src
		self.primary=self.fields[0][0]
		self.comment='inter_src'
		self.atable=self.object.inter.atable()
		self.atable.name=self.name
		self.atable.fields=self.fields
		self.atable.primary=self.primary
		self.atable.comment=self.comment

	def _countself(self):
		return self.atable.countself()
	
	def _create(self):
		return self.atable.create()
		
	def _drop(self):
		return self.atable.drop()

	def _select(self, columns=[], clause=[]):
		return self.atable.select(columns, clause)
		
	def _count(self, clause=[]):
		return self.atable.count(clause)
		
	def _delete(self, clause=[]):
		return self.atable.delete(clause)

	def _update(self, dict, clause=[]):
		return self.atable.update(dict, clause)

	def _insert(self, fields, values):
		return self.atable.insert(fields, values)

	#end of class inter_src suite

class inter_dest:
	"""This class is a manipulator for destination in intermediate db"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, object):
		self.object=object
		self.name=self.object.prefix+self.object.developer+self.object.project+self.object.name+'_dest'
		self.fields=self.object.fields_dest
		self.primary=self.fields[0][0]
		self.comment='inter_dest'
		self.atable=self.object.inter.atable()
		self.atable.name=self.name
		self.atable.fields=self.fields
		self.atable.primary=self.primary
		self.atable.comment=self.comment
	
	def _countself(self):
		return self.atable.countself()
	
	def _create(self):
		return self.atable.create()
		
	def _drop(self):
		return self.atable.drop()

	def _select(self, columns=[], clause=[]):
		return self.atable.select(columns, clause)
		
	def _count(self, clause=[]):
		return self.atable.count(clause)
		
	def _delete(self, clause=[]):
		return self.atable.delete(clause)

	def _update(self, dict, clause=[]):
		return self.atable.update(dict, clause)

	def _insert(self, fields, values):
		return self.atable.insert(fields, values)

	#end of class inter_dest suite

class inter_map:
	"""This class is a manipulator for map in intermediate db"""
	#print (self.__doc__)
	#beginning of class suite
	def __init__(self, object):
		self.object=object
		self.name=self.object.prefix+self.object.developer+self.object.project+self.object.name+'_map'
		self.fields=[object.fields_src[0]]+object.fields_src[1:]+object.fields_dest[1:]
		self.primary=self.fields[0][0]
		self.comment='inter_map'
		self.atable=self.object.inter.atable()
		self.atable.name=self.name
		self.atable.fields=self.fields
		self.atable.primary=self.primary
		self.atable.comment=self.comment
	
	def _countself(self):
		return self.atable.countself()
	
	def _create(self):
		return self.atable.create()
		
	def _drop(self):
		return self.atable.drop()

	def _select(self, columns=[], clause=[]):
		return self.atable.select(columns, clause)
			
	def _count(self, clause=[]):
		return self.atable.count(clause)
			
	def _delete(self, clause=[]):
		return self.atable.delete(clause)

	def _update(self, dict, clause=[]):
		return self.atable.update(dict, clause)

	def _insert(self, fields, values):
		return self.atable.insert(fields, values)
	
	#end of class inter_map suite